content type check test

Judy Ngai 9 gadi atpakaļ
vecāks
revīzija
87760f1135
1 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. 14 0
      spec/models/agents/email_agent_spec.rb

+ 14 - 0
spec/models/agents/email_agent_spec.rb

@@ -75,5 +75,19 @@ describe Agents::EmailAgent do
75 75
       expect(get_message_part(ActionMailer::Base.deliveries.last, /plain/).strip).to match(/\A\s*<strong>rain\!<\/strong>\s*\z/)
76 76
       expect(get_message_part(ActionMailer::Base.deliveries.last, /html/).strip).to match(/<body>\s*<strong>rain\!<\/strong>\s*<\/body>/)
77 77
     end
78
+    it "can take content type option to set content type of email sent" do
79
+      @checker.update_attributes :options => @checker.options.merge({
80
+        'content_type' => 'text/plain'
81
+      })
82
+
83
+      event2 = Event.new
84
+      event2.agent = agents(:bob_rain_notifier_agent)
85
+      event2.payload = { :foo => { :subject => "Something you should know about" }, :some_html => "<strong>rain!</strong>" }
86
+      event2.save!
87
+
88
+      Agents::EmailAgent.async_receive(@checker.id, [event2.id])
89
+
90
+      expect(ActionMailer::Base.deliveries.last.content_type).to eq("text/plain; charset=UTF-8")
91
+    end
78 92
   end
79 93
 end